package com.ruoyi.back.v1.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.Ok
import com.ruoyi.app.common.PageData
import com.ruoyi.back.v1.domain.*
import com.ruoyi.back.v1.service.*
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*


@RestController
@RequestMapping("/system/new")
@Api(tags = ["新增接口"])
class NewController {

    @Autowired
    private lateinit var freezeTimeService: FreezeTimeService

    @Autowired
    private lateinit var freeMemberShareService: FreeMemberShareService

    @Autowired
    private lateinit var freeMemberTaskService: FreeMemberTaskService

    @Autowired
    private lateinit var pointUseDetailService: PointUseDetailService

    @Autowired
    private lateinit var globalParamDetailService: GlobalParamDetailService

    @Autowired
    private lateinit var changeFaceApiDetailService: ChangeFaceApiDetailService


    @GetMapping("initFreezeTime")
    @ApiOperation("初始化冻结时间 -> 内部使用 前端可以不用关注此接口")
    fun initFreezeTime(): Data<Unit> = Ok("初始化成功", freezeTimeService.initFreezeTime())


    @GetMapping("freezeTimeList")
    @ApiOperation("获取用户冻结时间列表")
    fun freezeTimeList(): Data<List<FreezeTime>> = freezeTimeService.freezeTimeList()


    @PostMapping("saveFreeMemberTask")
    @ApiOperation("保存或者修改免费会员任务")
    fun saveFreeMemberTask(@RequestBody freeMember: FreeMember): Data<Boolean> =
        freeMemberTaskService.saveFreeMemberTask(freeMember)

    @GetMapping("removeFreeMemberTask")
    @ApiOperation("移除免费会员任务")
    fun removeFreeMemberTask(ids: String): Data<Boolean> = freeMemberTaskService.removeFreeMemberTask(ids)

    @GetMapping("freeMemberTaskList")
    @ApiOperation("获取免费会员任务列表")
    fun freeMemberTaskList() = freeMemberTaskService.freeMemberTaskList()


    @PostMapping("savePointUseDetail")
    @ApiOperation("保存或者修改点数消耗设置")
    fun savePointUseDetail(@RequestBody pointUseDetail: PointUseDetail): Data<Boolean> =
        pointUseDetailService.savePointUseDetail(pointUseDetail)


    @GetMapping("getPointUseDetail")
    @ApiOperation("获取点数消耗设置数据")
    fun getPointUseDetail() = pointUseDetailService.getPointUseDetail()


    @PostMapping("saveFreeMemberShare")
    @ApiOperation("保存或者修改免费会员分享设置")
    fun saveFreeMemberShare(@RequestBody freeMemberShare: FreeMemberShare) =
        freeMemberShareService.saveFreeMemberShare(freeMemberShare)


    @GetMapping("getFreeMemberShare")
    @ApiOperation("获取免费会员分享设置数据")
    fun getFreeMemberShare() = freeMemberShareService.getFreeMemberShare()


    @PostMapping("saveGlobalParamDetail")
    @ApiOperation("保存接口设置")
    fun saveGlobalParamDetail(@RequestBody globalParamDetail: GlobalParamDetail) =
        globalParamDetailService.saveGlobalParamDetail(globalParamDetail)


    @GetMapping("globalParamDetail")
    @ApiOperation("获取接口设置")
    fun globalParamDetail() = globalParamDetailService.globalParamDetail()


    @GetMapping("changeFaceApiDetailList")
    @ApiOperation("获取接口统计")
    fun changeFaceApiDetailList(apiStatisticsDto: ApiStatisticsDto): PageData<ApiStatisticsVo> =
        changeFaceApiDetailService.changeFaceApiDetailList(apiStatisticsDto)

    @GetMapping("apiTotalStatisticsVo")
    @ApiOperation("获取接口使用总统计")
    fun apiTotalStatisticsVo() = changeFaceApiDetailService.apiTotalStatisticsVo()
}